package com.tengju.data.infrastructure.repository.clickhouse.convert;

import com.tengju.data.domain.model.clickhouse.wechat.WechatUserInfo;
import com.tengju.data.domain.model.user.StarLevelEnum;
import com.tengju.data.domain.model.user.UserIdCode;
import com.tengju.data.domain.model.wx.WxActivateStatus;
import com.tengju.data.infrastructure.persistence.mybatis.dataobject.WechatUserInfoDO;

/**
 * @author: 李大仙
 * @date: 2021/12/15 3:01 下午
 */
public class WechatUserInfoConvert {
    public static WechatUserInfo convert(WechatUserInfoDO wechatUserInfoDO) {
        if (wechatUserInfoDO == null) {
            return null;
        }
        return new WechatUserInfo(
                UserIdCode.of(wechatUserInfoDO.getIdCode()),
                StarLevelEnum.parseByStarLevel(wechatUserInfoDO.getStarLevel()),
                wechatUserInfoDO.getWxActivateStatus() != 0 ? WxActivateStatus.form(wechatUserInfoDO.getWxActivateStatus()) : WxActivateStatus.SPECIAL,
                wechatUserInfoDO.getUserName(),
                UserIdCode.of(wechatUserInfoDO.getBlStar1IdCode()),
                wechatUserInfoDO.getBlStar1Name(),
                UserIdCode.of(wechatUserInfoDO.getBlStar2IdCode()),
                wechatUserInfoDO.getBlStar2Name(),
                UserIdCode.of(wechatUserInfoDO.getBlStar3IdCode()),
                wechatUserInfoDO.getBlStar3Name(),
                UserIdCode.of(wechatUserInfoDO.getBlStar4IdCode()),
                wechatUserInfoDO.getBlStar4Name(),
                UserIdCode.of(wechatUserInfoDO.getBlEcIdCode()),
                wechatUserInfoDO.getBlEcName(),
                UserIdCode.of(wechatUserInfoDO.getBlSecIdCode()),
                wechatUserInfoDO.getBlSecName()
        );
    }
}
